package xyz.xiezc.mzix.download;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xyz.xiezc.mzix.download.feign.ScheduleService;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class DownloadApplication {

    public static void main(String[] args) {
        SpringApplication.run(DownloadApplication.class, args);
    }


    @RefreshScope
    @RestController
    class EchoController {

        @Autowired
        ScheduleService scheduleService;


        @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
        public String echo(@PathVariable String string) {
            scheduleService.setSession("download", "xxx", string);
            String session = scheduleService.getSession("download", "xxx");
            return "Hello Nacos Discovery " + session;
        }
    }
}